package io.renren.modules.oss.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.renren.common.pojo.Query;
import io.renren.modules.common.BaseService;
import io.renren.modules.oss.dao.SysOssDao;
import io.renren.modules.oss.entity.SysOssEntity;
import io.renren.modules.oss.service.SysOssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("sysOssService")
public class SysOssServiceImpl extends BaseService
		implements SysOssService {
	@Autowired
	private SysOssDao sysOssDao;
	
	@Override
	public SysOssEntity queryObject(Long id){
		return sysOssDao.queryObject(id);
	}
	
	@Override
	public List<SysOssEntity> queryList(Query query){
		return sysOssDao.queryList(query);
	}

	@Override
	public PageInfo<SysOssEntity> queryPage(Query query) {
		return PageHelper.startPage(query.getPage(),query.getLimit())
				.doSelectPageInfo(() -> sysOssDao.queryList(query));
	}

	@Override
	public long queryTotal(Query query){
		return PageHelper.count(() -> sysOssDao.queryList(query));
	}
	
	@Override
	@Transactional
	public void save(SysOssEntity sysOss){
		sysOssDao.save(sysOss);
	}
	
	@Override
	@Transactional
	public void update(SysOssEntity sysOss){
		sysOssDao.update(sysOss);
	}
	
	@Override
	@Transactional
	public void delete(Long id){
		sysOssDao.delete(id);
	}
	
	@Override
	@Transactional
	public void deleteBatch(Long[] ids){
		sysOssDao.deleteBatch(ids);
	}
	
}
